import java.util.Random;
import java.util.Scanner;

/**
 * @author: gao
 * @create-date: 2025/4/4 11:31
 */

public class Solution {
    public int findKthLargest(int[] nums, int k) {
        return Quicksort(nums, 0, nums.length - 1, k);
    }

    private int Quicksort(int[] nums, int l, int r, int k) {
        if (l == r) return nums[l];

        //随机选择基准元素
        int key = nums[new Random().nextInt(r - l + 1) + l];

        //根据基准元素，把数组分为三块
        int left = l - 1, right = r + 1, i = l;
        while (i < right) {
            if (nums[i] < key) swap(nums, ++left, i++);
            else if (nums[i] == key) i++;
            else if (nums[i] > key) swap(nums, --right, i);
        }
        //分类讨论
        //区间:[l,left],[left+1,right-1],[right,r]
        int b = right - left - 1, c = r - right + 1;
        if (c >= k) return Quicksort(nums, right, r, k);
        else if (b + c >= k) return key;
        else return Quicksort(nums, l, left, k - b - c);
    }

    private void swap(int[] nums, int i, int j) {
        int tmp = nums[i];
        nums[i] = nums[j];
        nums[j] = tmp;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {
            int len = in.nextInt();
            int[] nums = new int[len];
            for (int i = 0; i < len; i++) {
                nums[i] = in.nextInt();
            }
            int k = in.nextInt();
            Solution solution = new Solution();
            System.out.println(solution.findKthLargest(nums, k));
        }
    }
}